from fake_useragent import UserAgent

ua = UserAgent()

# 获取随机 User-Agent
random_user_agent = ua.random

print(random_user_agent)

headers = {
    "User-Agent": random_user_agent
}

# 使用 requests 库发送请求时，将 headers 传递给 requests.get() 方法
# response = requests.get(url, headers=headers)